package cn.kgc.se.day06.work;

/**
 * @author 课工场
 * @date 2024/3/21
 * @description
 *  使用switch选择结构实现判断某年某月某日是这一年的第几天？
 */
public class Demo16 {

    public static void main(String[] args) {

        // 2024 3 22

        int year = 2024;
        int month = 3;
        int day = 22;

        // 定义变量  存储当前年份是什么年 平年 闰年
        boolean leapYear =  false;
        if ((year%4==0&&year%100!=0)||(year%400==0)){
            leapYear = true;
        }

        int sumDay = 0;
        // 判定已经过去的月份共有多少天
        switch (month-1){
            case 12:
                sumDay+=31;
            case 11:
                sumDay+=30;
            case 10:
                sumDay+=31;
            case 9:
                sumDay+=30;
            case 8:
                sumDay+=31;
                break;
            case 7:
                sumDay+=31;
            case 6:
                sumDay+=30;
            case 5:
                sumDay+=31;
            case 4:
                sumDay+=30;
            case 3:
                sumDay+=31;
            case 2:
                sumDay+= leapYear ? 29:28;
            case 1:
                sumDay+=31;

        }


        System.out.println("今天是该年份的第"+(sumDay+day)+"天");

    }
}
